package com.hyjy.music.util

import android.widget.Toast
import androidx.annotation.StringRes
import com.hyjy.music.ContextHolder

private var toast: Toast? = null

fun showToast(text: CharSequence, duration: Int = Toast.LENGTH_SHORT) {
    toast?.cancel()
    toast = Toast.makeText(ContextHolder.context, text, duration).apply {
        show()
    }
}

fun showToast(@StringRes id: Int, duration: Int = Toast.LENGTH_SHORT) {
    toast?.cancel()
    toast = Toast.makeText(ContextHolder.context, id, duration).apply {
        show()
    }
}